﻿//********************************************************************************************************
// Product Name: MapWindowTools Function Testing
// Description:  Batch Testing the function of MapWindowTools Function
//********************************************************************************************************
//1 open the input file
//2 run buffer
//3 get the output file 
//4 compare the output file to a "known" correct output file.
// Contributor(s): (Open source contributors should list themselves and their modifications here). 
// -----------------------|------------------------|---------------------------------------------------------------
// Ping Yang              |  01/2010               |  Use this for the testing the algorithms in the MapWindowTools. 
//******************************************************************************************************************


using System;
using System.Collections;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel.Design;
using System.Reflection;
using System.Xml;
using MapWindow;
using MapWindow.Tools;
using MapWindow.Data;
using MapWindow.Tools.Param;
using MapWindow.Main;
using MapWindow.Components;
using MapWindow.Drawing;
using MapWindow.Forms;
using MapWindowTools.Conversion;
using MapWindow.Projections;


namespace MapWindowTool_Tests
{
    //public partial class Form1 : Form, ICancelProgressHandler
    //Failed in inheriting from the ICancelProgressHandler which tried to get a ICancelProgressHandler parameter
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnBegin_Click(object sender, EventArgs e)
        {
            PingHandler CancelHandle = new PingHandler();

            TestVoronoi(CancelHandle);//!slow

            //--------Test in Statictics-------------//
            TestArea(CancelHandle);

            //--------Test in SpatialReference-------------//
            TestReprojectFeatureSet(CancelHandle);

            //--------Test in VectorOverlay-------------//
            TestAggregate(CancelHandle);
            TestAddFeature(CancelHandle);
            TestDeleteFeatures(CancelHandle);
            TestGenerateCentroid(CancelHandle);
            TestClipPolygonWithLine(CancelHandle);
            TestClipPolygonWithPolygon(CancelHandle);
            TestOverWriteFeature(CancelHandle);
            TestUnion(CancelHandle);

            //--------Test in Analysis-------------//
            TestBuffer(CancelHandle);
            TestErase();
            TestMergeGrids(CancelHandle);

            TestClipWithPolygon(CancelHandle);

            //--------Test in Conversion-------------//
            TestFeatureToRaster(CancelHandle);
            TestRasterToPolygon(CancelHandle);//have problem

            //--------Test in Generalisation-------------//
            TestDPSimplification(CancelHandle);

            //--------Test in Raster Overlay-------------//
            TestRasterAdd(CancelHandle);
            TestRasterSubract(CancelHandle);
            TestNoDataValueChange(CancelHandle);
            TestRasterDistance(CancelHandle);
            TestReSampleGrid(CancelHandle);
            TestRasterMultiply(CancelHandle);

            //--------Test in Terrain Analysis-------------//
            TestFindAveregeSlope(CancelHandle);
            TestFindAveregeSlopeExtented(CancelHandle);
            TestRasterSlope(CancelHandle);
        }
        //**********CompareBinary function for Compare the Byte of the output this time with that of output last time(Correct Output)************/
        //take two input files name(Raster or featureset) and return a boolean "true or false" depending on if the two files match
        public bool CompareBinary(string OutputFilename, string CorrectFilename)
        {
            int i = 0, j = 0;
            FileStream f1 = new FileStream(OutputFilename, FileMode.Open, FileAccess.Read, FileShare.Read);
            FileStream f2 = new FileStream(CorrectFilename, FileMode.Open, FileAccess.Read, FileShare.Read);
            try
            {
                do
                {
                    i = f1.ReadByte();
                    j = f2.ReadByte();
                    if (i != j) break;
                } while (i != -1 && j != -1);
            }
            catch (IOException exc)
            {
                Console.WriteLine(exc.Message);
            }
            f1.Close();
            f2.Close();
            if (i != j)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

      
        //**********CompareFeatures function for Compare the features of the output this time with that of output last time(Correct Output)************/
        //take two input files(or featureset) and return a boolean "true or false" depending on if the two files match
        public bool CompareFeatures(IFeatureSet TestOutput, IFeatureSet TestCorrect)
        {
            bool FeatureFlag = true;
            if (TestOutput.Features.Count != TestCorrect.Features.Count)
                FeatureFlag = false;
            else
                if ((TestOutput.Vertex.Length) != (TestCorrect.Vertex.Length))
                {
                    FeatureFlag = false;
                }
                else
                {
                    for (int i = 0; i < (TestOutput.Vertex.Length); i++)
                    {
                        if (TestOutput.Vertex.GetValue(i).ToString() != TestCorrect.Vertex.GetValue(i).ToString())
                            FeatureFlag = false;
                    }
                }
            return FeatureFlag;
        }

        //**********CompareAttribute function for Compare the attributes of the output this time with that of output last time(Correct Output)************/
        //take two input files(or featureset) and return a boolean "true or false" depending on if the two files match
        public bool CompareAttribute(IFeatureSet TestOutput, IFeatureSet TestCorrect)
        {

            AttributeTable TempTable1 = new AttributeTable();
            AttributeTable TempTable2 = new AttributeTable();
            bool AttributeFlag = true;
            TempTable1.Open(TestOutput.Filename);
            //TempTable1.Open("../../TestData/OutputData\\Aggregate\\US_States.shp");
            TempTable2.Open(TestCorrect.Filename);
            //TempTable2.Open("../../TestData/OutputData\\Aggregate\\US_States.shp");

            if ((TempTable1.NumRecords != TempTable2.NumRecords) || (TempTable1.Columns.Count != TempTable2.Columns.Count))
            {
                AttributeFlag = false;
            }
            else
            {
                DataTable Table1 = new DataTable();
                DataTable Table2 = new DataTable();
                Table1 = TempTable1.Table;
                Table2 = TempTable2.Table;
                ArrayList table1List = new ArrayList();
                ArrayList table2List = new ArrayList();

                DataRow[] currentRows1 = Table1.Select(null, null, DataViewRowState.CurrentRows);
                DataRow[] currentRows2 = Table2.Select(null, null, DataViewRowState.CurrentRows);
                if ((currentRows1.Length < 1) && (currentRows2.Length < 1))
                {
                    lstOutput.Items.Add("No Records in attribute table");
                }

                else
                {
                    foreach (DataRow row in currentRows1)
                    {
                        foreach (DataColumn column in Table1.Columns)
                            table1List.Add(row[column].ToString());
                    }
                    foreach (DataRow row in currentRows1)
                    {
                        foreach (DataColumn column in Table1.Columns)
                            table2List.Add(row[column].ToString());
                    }
                    if (table1List.Count == table2List.Count)
                    {
                        for (int i = 0; i < table1List.Count; i++)
                        {
                            if ((table1List[i].ToString() != table2List[i].ToString()))
                                AttributeFlag = false;
                        }
                    }
                }

            }
            return AttributeFlag;
        }

        //**********CompareRasterValues function for Compare the Raster Values of the output this time with that of output last time(Correct Output)************/
        //take two input files(Two Raster file) and return a boolean "true or false" depending on if the two files match
        public bool CompareRasterValues(IRaster TestOutput, IRaster TestCorrect)
        {
            bool RasterValueFlag = true;
            if ((TestOutput.NumBands != TestCorrect.NumBands) || (TestOutput.NumColumns != TestCorrect.NumColumns) || (TestOutput.NumRows != TestCorrect.NumRows))
            {
                RasterValueFlag = false;
            }
            else
            {
                for (int i = 0; i < TestOutput.NumRows; i++)
                {
                    for (int j = 0; j < TestOutput.NumColumns; j++)
                    {
                        if (TestOutput.Value[i, j].ToString() != TestCorrect.Value[i, j].ToString())
                            RasterValueFlag = false;
                    }
                }
            }

            return RasterValueFlag;
        }
        public void TestRasterAdd(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing TestRasterAdd function");
            lstOutput.Update();
            Raster TestInput1 = new Raster();
            Raster TestInput2 = new Raster();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/RasterAdd/iron1.bgd");
            TestInput2.Open("../../TestData/InputData/RasterAdd/iron2.bgd");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/RasterAdd/OutputIron.bgd");
            //3 Get the Object and Execute the function
            MapWindowTools.mwRasterAdd TestRasterAdd = new MapWindowTools.mwRasterAdd();
            TestRasterAdd.Execute(TestInput1, TestInput2, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/RasterAdd/correctiron.bgd");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("RasterAdd function passed testing in " + TestInput1.Filename.ToString() +" and "+ TestInput2.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("RasterAdd function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("RasterAdd function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
            lstOutput.Update();
        }
        //Testing for RasterSubract function
        public void TestRasterSubract(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing TestRasterSubract function");
            lstOutput.Update();
            Raster TestInput1 = new Raster();
            Raster TestInput2 = new Raster();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/RasterSubract/iron1.bgd");
            TestInput2.Open("../../TestData/InputData/RasterSubract/iron2.bgd");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/RasterSubract/OutputIron.bgd");
            //3 Get the Object and Execute the function
            MapWindowTools.mwRasterSubract TestRasterSubract = new MapWindowTools.mwRasterSubract();
            TestRasterSubract.Execute(TestInput1, TestInput2, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/RasterSubract/CorrectIron.bgd");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("RasterSubract function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("RasterSubract function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("RasterSubract function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
            lstOutput.Update();
        }
        public void TestAggregate(ICancelProgressHandler CancelHandle)
        {
            //"Now testing aggregate function"
            //lstOutput.GetItemText("Now testing aggregate function");
            lstOutput.Items.Add("Now testing aggregate function");
            lstOutput.Update();
            FeatureSet TestInput = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/Aggregate/Polygons.shp");
            MapWindowTools.mwAggregate TestAggObject = new MapWindowTools.mwAggregate();
            //2 run aggregate and 
            TestOutput.Filename = "../../TestData/OutputData/Aggregate/AGGPolygons.shp";
            //TestAggObject.Execute(TestInput, TestOutput);
            TestAggObject.Execute(TestInput, TestOutput, CancelHandle);
            //4 compare the output file to a "known" correct output file.
            TestCorrect.Open("../../TestData/CorrectOutput/Aggregate/CorrectAGGPolygons.shp");
            //pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("aggregate function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect) && CompareAttribute(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("aggregate function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("aggregate function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        public void TestBuffer(ICancelProgressHandler CancelHander)
        {
            lstOutput.Items.Add("Now testing Buffer function");
            lstOutput.Update();
            IFeatureSet TestInput = new FeatureSet();
            IFeatureSet TestOutput = new FeatureSet();
            IFeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            MapWindow.Data.Shapefile sfInput = new Shapefile();
            sfInput.Open("../../TestData/InputData/Buffer/PolygonToBuffer.shp");
            TestInput = sfInput;
            //2 Name and locate the outputfile.
            TestOutput.Filename = "../../TestData/OutputData/Buffer/BufferedPolygon.shp";
            //3 Get the Object and Execute the function, The Default buffer distance set to be 10
            MapWindowTools.mwBuffer TestBuffer = new MapWindowTools.mwBuffer();
            Double BufferDistance = 10.0;
            TestBuffer.Execute(TestInput, BufferDistance, TestOutput, CancelHander);
            //4 Open a "known" correct output file  
            MapWindow.Data.Shapefile sfCorrectfile = new Shapefile();
            sfCorrectfile.Open(@"../../TestData/CorrectOutput/Buffer/CorrectBuffer.shp");
            TestCorrect = sfCorrectfile;

            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("Buffer function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect) && CompareAttribute(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("Buffer function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("Buffer function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();     
        }
        /// <summary>
        /// Test the Area Calculation Function 
        /// </summary>
        /// <param name="TestInput1">The input feature that is to be Calculated</param>
        /// <param name="TestOutput">The resulting erased content</param>
        /// <returns>void</returns>
        public void TestArea(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing Area function");
            lstOutput.Update();
            FeatureSet TestInput = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            MapWindow.Data.Shapefile sfInput = new Shapefile();
            //Name and locate the outputfile.
            sfInput.Open("../../TestData/InputData/Area/PolygonArea.shp");
            TestInput = sfInput;
            MapWindowTools.mwArea TestAreaObject = new MapWindowTools.mwArea();
            //2 run area  
            TestOutput.Filename = "../../TestData/OutputData/Area/OutputPolygonArea.shp";
            TestAreaObject.Execute(TestInput, TestOutput, CancelHandle);
            //4 compare the output file to a "known" correct output file.
            TestCorrect.Open("../../TestData/CorrectOutput/Area/CorrectPolygonArea.shp");
            //pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("Area function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect) && CompareAttribute(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("Area function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("Area function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();

        }
        /// <summary>
        /// Test the Erase Function 
        /// </summary>
        /// <param name="TestInput1">The input feature that is to be erased</param>
        /// <param name="TestInput2">The other feature defining the area to remove</param>
        /// <param name="TestOutput">The resulting erased content</param>
        /// <returns>void</returns>
        public void TestErase()
        {
            lstOutput.Items.Add("Now testing Erase function");
            lstOutput.Update();
            FeatureSet TestInput1 = new FeatureSet();
            FeatureSet TestInput2 = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/Erase/EraseInput1.shp");
            TestInput2.Open("../../TestData/InputData/Erase/EraseInput2.shp");
            //2 Name and locate the outputfile. TestOutput.Filename=
            TestOutput.Filename = "../../TestData/InputData/Erase/EraseOutput.shp";
            //3 Get the Object and Execute the function, The Default buffer distance set to be 10
            MapWindowTools.mwErase TestErase = new MapWindowTools.mwErase();
            //TestErase.Execute(TestInput1, sfInput2, TestOutput);
            TestErase.Execute(TestInput1, TestInput2, TestOutput);
            //4 Open a "known" correct output file  
            TestCorrect.Open("../../TestData/CorrectOutput/Erase/CorrectEraseOutput.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("Erase function passed testing in " + TestInput1.Filename.ToString()+" and " + TestInput2.Filename.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect) && CompareAttribute(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("Erase function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("Erase function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
            lstOutput.Update();
        }
        /// <summary>
        /// Test the Line Simplification Function 
        /// </summary>
        /// <param name="TestInput1">The input feature that is to be Simplified</param>
        /// <param name="TestOutput">The resulting erased content</param>
        /// <returns>void</returns>
        public void TestDPSimplification(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing DPSimplification function");
            lstOutput.Update();
            FeatureSet TestInput = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //ICancelProgressHandler Handle = CancelProgress as ICancelProgressHandler;
            //1 open the input file
            TestInput.Open(@"../../TestData/InputData/DPSimplification/Snake.shp");
            //2 Name and locate the outputfile.
            TestOutput.Filename = "../../TestData/OutputData/DPSimplification/SimplifiedSnake.shp";
            //3 Get the Object and Execute the function, The Default buffer distance set to be 10
            MapWindowTools.mwDPSimplification TestDPSimplification = new MapWindowTools.mwDPSimplification();
            Double Tolerance = 10;
            //TestDPSimplification.Execute(TestInput, Tolerance, TestOutput);
            TestDPSimplification.Execute(TestInput, Tolerance, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput\\DPSimplification\\CorrectSimplifiedSnake.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("DPSimplification function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect) && CompareAttribute(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("DPSimplification function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("DPSimplification function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        //TestNoDataValueChange
        public void TestNoDataValueChange(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing NoDataValueChange function");
            lstOutput.Update();
            Raster TestInput = new Raster();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/NodataValueChange/iron1.bgd");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/NodataValueChange/OutputIron.bgd");
            //3 Get the Object and Execute the function
            double Value1, Value2;
            Value1 = -1;
            Value2 = 2;
            MapWindowTools.mwNoDataValueChange TestNoDataValueChange = new MapWindowTools.mwNoDataValueChange();
            TestNoDataValueChange.Execute(TestInput, Value1, Value2, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/NodataValueChange/CorrectNodataValue.bgd");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("NoDataValueChange function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("NoDataValueChange function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("NoDataValueChange function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        void TestRasterDistance(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing RasterDistance function");
            lstOutput.Update();
            Raster TestInput = new Raster();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/RasterDistance/iron1.bgd");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/RasterDistance/OutputIron.bgd");
            //3 Get the Object and Execute the function
            double maxDistance;
            maxDistance = 100;
            MapWindowTools.mwRasterDistance TestRasterDistance = new MapWindowTools.mwRasterDistance();
            TestRasterDistance.Execute(TestInput,TestOutput ,maxDistance, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/RasterDistance/CorrectRasterDistance.bgd");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("RasterDistance function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("RasterDistance function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("RasterDistance function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        //mwRasterMultiply
        void TestRasterMultiply(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing RasterMultiply function");
            lstOutput.Update();
            Raster TestInput1 = new Raster();
            Raster TestInput2 = new Raster();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/RasterMultiply/iron1.bgd");
            TestInput2.Open("../../TestData/InputData/RasterMultiply/lone_mtn.bgd");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/RasterMultiply/OutputIron.bgd");
            //3 Get the Object and Execute the function
            MapWindowTools.mwRasterMultiply TestRasterMultiply = new MapWindowTools.mwRasterMultiply();
            TestRasterMultiply.Execute(TestInput1,TestInput2,TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/RasterMultiply/CorrectRasterMultiply.bgd");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("RasterMultiply function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("RasterMultiply function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("RasterMultiply function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
            lstOutput.Update();
        }
        //mwReSampleGrid
        void TestReSampleGrid(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing ReSampleGrid function");
            lstOutput.Update();
            Raster TestInput = new Raster();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/ReSampleGrid/iron1.bgd");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/ReSampleGrid/OutputIron.bgd");
            //3 Get the Object and Execute the function
            double newCellHeight, newCellWidth;
            newCellHeight = 100;
            newCellWidth = 100;
            MapWindowTools.mwReSampleGrid TestReSampleGrid = new MapWindowTools.mwReSampleGrid();
            TestReSampleGrid.Execute(TestInput, newCellHeight, newCellWidth, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/ReSampleGrid/CorrectReSampleGrid.bgd");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("ReSampleGrid function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("ReSampleGrid function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("ReSampleGrid function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        //mwClipWithPolygon, have some problem???
        void TestClipWithPolygon(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing ClipWithPolygon function");
            lstOutput.Update();
            Raster TestInput1 = new Raster();
            FeatureSet TestInput2 = new FeatureSet();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/ClipWithPolygon/iron1.bgd");
            TestInput2.Open("../../TestData/InputData/ClipWithPolygon/PolygonToClip.shp");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/ClipWithPolygon/OutputClip.bgd");
            //3 Get the Object and Execute the function
            MapWindowTools.mwClipWithPolygon TestClipWithPolygon = new MapWindowTools.mwClipWithPolygon();
            TestClipWithPolygon.Execute(TestInput1, TestInput2, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/ClipWithPolygon/correctclilpedraster.bgd");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("ClipWithPolygon function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("ClipWithPolygon function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("ClipWithPolygon function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
            lstOutput.Update();
        }
        //MergeGrids
        void TestMergeGrids(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing MergeGrids function");
            lstOutput.Update();
            Raster TestInput1 = new Raster();
            Raster TestInput2 = new Raster();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/MergeGrids/iron1.bgd");
            TestInput2.Open("../../TestData/InputData/MergeGrids/iron1.bgd");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/MergeGrids/OutputMergeGrids.bgd");
            //3 Get the Object and Execute the function
            MapWindowTools.mwMergeGrids TestMergeGrids = new MapWindowTools.mwMergeGrids();
            TestMergeGrids.Execute(TestInput1, TestInput2, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/MergeGrids/CorrectMergeGrids.bgd");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("MergeGrids function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("MergeGrids function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("MergeGrids function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
            lstOutput.Update();
        }
        //Voronoi
        void TestVoronoi(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing Voronoi function");
            lstOutput.Update();
            FeatureSet TestInput = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/Voronoi/pcs3.shp");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/Voronoi/OutputVoronoi.shp");
            //3 Get the Object and Execute the function
            MapWindowTools.mwVoronoi TestVoronoi = new MapWindowTools.mwVoronoi();
            TestVoronoi.Execute(TestInput, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/Voronoi/CorrectVoronoi.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("Voronoi function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("Voronoi function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("Voronoi function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        //FeatureToRaster
        void TestFeatureToRaster(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing FeatureToRaster function");
            lstOutput.Update();
            FeatureSet TestInput = new FeatureSet();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/FeatureToRaster/Polygon.shp");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/FeatureToRaster/OutputFeatureToRaster.bgd");
            //3 Get the Object and Execute the function
            double cellsize;
            string fieldname;
            cellsize = 10;
            fieldname = "FID";
            MapWindowTools.Conversion.mwFeatureToRaster TestFeatureToRaster = new MapWindowTools.Conversion.mwFeatureToRaster();
            TestFeatureToRaster.Execute(TestInput,cellsize,fieldname, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/FeatureToRaster/CorrectFeatureToRaster.bgd");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("FeatureToRaster function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("FeatureToRaster function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("FeatureToRaster function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        //RasterToPolygon???
        void TestRasterToPolygon(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing RasterToPolygon function");
            lstOutput.Update();
            Raster TestInput = new Raster();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/RasterToPolygon/iron1.bgd");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/RasterToPolygon/OutputRasterToPolygon.shp");
            //3 Get the Object and Execute the function
            MapWindowTools.Conversion.mwRasterToPolygon TestRasterToPolygon = new MapWindowTools.Conversion.mwRasterToPolygon();
            TestRasterToPolygon.Execute(TestInput, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/RasterToPolygon/CorrectRasterToPolygon.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("RasterToPolygon function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("RasterToPolygon function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("RasterToPolygon function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        //IDW, the process is very slow???
        void TestIDW(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing IDW function");
            lstOutput.Update();
            FeatureSet TestInput = new FeatureSet();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/IDW/iron1.bgd");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/IDW/OutputIDW.shp");
            //3 Get the Object and Execute the function
            string zField = "TELE";
            double cellSize = 51.0;
            double power = 2.0;
            //NeighborhoodType neighborType = NeighborhoodType.FixedCount;
            int pointCount = 12;
            double distance = 0;
            MapWindowTools.mwIDW TestIDW = new MapWindowTools.mwIDW();
            //TestIDW.Execute(TestInput, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/IDW/CorrectIDW.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("IDW function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("IDW function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("IDW function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        //AddFeature
        void TestAddFeature(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing AddFeature function");
            lstOutput.Update();
            FeatureSet TestInput1 = new FeatureSet();
            FeatureSet TestInput2 = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/AddFeature/Input1.shp");
            TestInput2.Open("../../TestData/InputData/AddFeature/Input2.shp");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/AddFeature/OutputAddFeature.shp");
            //3 Get the Object and Execute the function
            MapWindowTools.Vector_Overlay_Class.mwAddFeature TestAddFeature = new MapWindowTools.Vector_Overlay_Class.mwAddFeature();
            TestAddFeature.Execute(TestInput1, TestInput2,TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/AddFeature/CorrectAddFeature.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("AddFeature function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("AddFeature function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("AddFeature function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.Filename.ToString());
                }
            lstOutput.Update();
        }
        //DeleteFeatures
        void TestDeleteFeatures(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing DeleteFeatures function");
            lstOutput.Update();
            FeatureSet TestInput1 = new FeatureSet();
            string TestInput2;
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/DeleteFeatures/US_States.shp");
            TestInput2 = "[AREA] > 100000";
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/DeleteFeatures/OutputDeleteFeatures.shp");
            //3 Get the Object and Execute the function
            MapWindowTools.Analysis_Class.mwDeleteFeatures TestDeleteFeatures = new MapWindowTools.Analysis_Class.mwDeleteFeatures();
            TestDeleteFeatures.Execute(TestInput1, TestInput2, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/DeleteFeatures/CorrectDeleteFeatures.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("DeleteFeatures function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("DeleteFeatures function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
                else
                {
                    lstOutput.Items.Add("DeleteFeatures function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
            lstOutput.Update();
        }
        //GenerateCentroid
        void TestGenerateCentroid(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing GenerateCentroid function");
            lstOutput.Update();
            FeatureSet TestInput = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/GenerateCentroid/polygons.shp");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/GenerateCentroid/OutputGenerateCentroid.shp");
            //3 Get the Object and Execute the function
            MapWindowTools.Vector_Overlay_Class.mwGenerateCentroid TestGenerateCentroid = new MapWindowTools.Vector_Overlay_Class.mwGenerateCentroid();
            TestGenerateCentroid.Execute(TestInput, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/GenerateCentroid/CorrectGenerateCentroid.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("GenerateCentroid function passed testing in " + TestInput.Filename.ToString() );
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("GenerateCentroid function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("GenerateCentroid function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        //ClipPolygonWithLine
        void TestClipPolygonWithLine(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing ClipPolygonWithLine function");
            lstOutput.Update();
            FeatureSet TestInput1 = new FeatureSet();
            FeatureSet TestInput2 = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/ClipPolygonWithLine/polygontoclip.shp");
            TestInput2.Open("../../TestData/InputData/ClipPolygonWithLine/clipline.shp");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/ClipPolygonWithLine/OutputGenerateCentroid.shp");
            //3 Get the Object and Execute the function
            MapWindowTools.mwClipPolygonWithLine TestClipPolygonWithLine = new MapWindowTools.mwClipPolygonWithLine();
            TestClipPolygonWithLine.Execute(TestInput1, TestInput2,TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/ClipPolygonWithLine/CorrectClipPolygonWithLine.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("ClipPolygonWithLine function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("ClipPolygonWithLine function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
                else
                {
                    lstOutput.Items.Add("ClipPolygonWithLine function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
            lstOutput.Update();
        }
        //ClipPolygonWithPolygon
        void TestClipPolygonWithPolygon(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing ClipPolygonWithPolygon function");
            lstOutput.Update();
            FeatureSet TestInput1 = new FeatureSet();
            FeatureSet TestInput2 = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/ClipPolygonWithPolygon/originpolygon.shp");
            //2 Name and locate the outputfile.
            TestInput2.Open("../../TestData/InputData/ClipPolygonWithPolygon/polygontoclip.shp");
            TestOutput.Filename = ("../../TestData/OutputData/ClipPolygonWithPolygon/OutputClipPolygonWithPolygon.shp");
            //3 Get the Object and Execute the function
            MapWindowTools.mwClipPolygonWithPolygon TestClipPolygonWithPolygon = new MapWindowTools.mwClipPolygonWithPolygon();
            TestClipPolygonWithPolygon.Execute(TestInput1, TestInput2,TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/ClipPolygonWithPolygon/CorrectClipPolygonWithPolygon.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("ClipPolygonWithPolygon function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("ClipPolygonWithPolygon function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
                else
                {
                    lstOutput.Items.Add("ClipPolygonWithPolygon function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
            lstOutput.Update();
        }
        //ReprojectFeatureSet????
        void TestReprojectFeatureSet(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing ReprojectFeatureSet function");
            lstOutput.Update();
            FeatureSet TestInput = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/ReprojectFeatureSet/countiestoreproject.shp");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/ReprojectFeatureSet/OutputReprojectFeatureSet.shp");
            //3 Get the Object and Execute the function
            //TestInput.FillAttributes();
            ProjectionInfo SourceProInfo = TestInput.Projection;
            ProjectionInfo pDest = MapWindow.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
            MapWindowTools.Analysis_Class.mwReprojectFeatureSet TestReprojectFeatureSet = new MapWindowTools.Analysis_Class.mwReprojectFeatureSet();
            TestReprojectFeatureSet.Execute(TestInput, SourceProInfo, pDest,TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/ReprojectFeatureSet/CorrectReprojectFeatureSet.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("ReprojectFeatureSet function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("ReprojectFeatureSet function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("ReprojectFeatureSet function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
        //OverWriteFeature
        void TestOverWriteFeature(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing OverWriteFeature function");
            lstOutput.Update();
            FeatureSet TestInput1 = new FeatureSet();
            FeatureSet TestInput2 = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/OverWriteFeature/Input1.shp");
            //2 Name and locate the outputfile.
            TestInput2.Open("../../TestData/InputData/OverWriteFeature/Input2.shp");
            TestOutput.Filename = ("../../TestData/OutputData/OverWriteFeature/OutputOverWriteFeature.shp");
            //3 Get the Object and Execute the function
            int index = 0;
            MapWindowTools.Vector_Overlay_Class.mwOverWriteFeature TestOverWriteFeature = new MapWindowTools.Vector_Overlay_Class.mwOverWriteFeature();
            TestOverWriteFeature.Execute(TestInput1, index,TestInput2, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/OverWriteFeature/CorrectOverWriteFeature.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("OverWriteFeature function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("OverWriteFeature function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
                else
                {
                    lstOutput.Items.Add("OverWriteFeature function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
            lstOutput.Update();
        }
        //Union
        void TestUnion(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing Union function");
            lstOutput.Update();
            FeatureSet TestInput1 = new FeatureSet();
            FeatureSet TestInput2 = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/Union/Input1.shp");
            //2 Name and locate the outputfile.
            TestInput2.Open("../../TestData/InputData/Union/Input2.shp");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/Union/OutputUnion.shp");
            //3 Get the Object and Execute the function
            MapWindowTools.mwUnion TestUnion = new MapWindowTools.mwUnion();
            if(TestInput1.Features.Count<TestInput2.Features.Count)
            {
                TestUnion.Execute(TestInput1, TestInput2,TestOutput, CancelHandle);
            }
            else
            {
                TestUnion.Execute(TestInput2, TestInput1,TestOutput, CancelHandle);
            }
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/Union/CorrectUnion.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("Union function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("Union function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
                else
                {
                    lstOutput.Items.Add("Union function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
            lstOutput.Update();
        }
        void TestFindAveregeSlope(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing FindAveregeSlope function");
            lstOutput.Update();
            Raster TestInput1 = new Raster();
            FeatureSet TestInput2 = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/FindAveregeSlope/iron1.bgd");
            //2 Name and locate the outputfile.
            TestInput2.Open("../../TestData/InputData/FindAveregeSlope/PolygonIron.shp");
            TestOutput.Filename = ("../../TestData/OutputData/FindAveregeSlope/OutputOverWriteFeature.shp");
            //3 Get the Object and Execute the function
            int index = 1;
            MapWindowTools.Terrain_Analysis.mwFindAveregeSlope TestFindAveregeSlope = new MapWindowTools.Terrain_Analysis.mwFindAveregeSlope();
            TestFindAveregeSlope.Execute(TestInput1, index, TestInput2, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/FindAveregeSlope/CorrectFindAveregeSlope.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("FindAveregeSlope function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("FindAveregeSlope function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
                else
                {
                    lstOutput.Items.Add("FindAveregeSlope function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
            lstOutput.Update();
        }
        void TestFindAveregeSlopeExtented(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing FindAveregeSlopeExtented function");
            lstOutput.Update();
            Raster TestInput1 = new Raster();
            FeatureSet TestInput2 = new FeatureSet();
            FeatureSet TestOutput = new FeatureSet();
            FeatureSet TestCorrect = new FeatureSet();
            //1 open the input file
            TestInput1.Open("../../TestData/InputData/FindAveregeSlopeExtented/iron1.bgd");
            //2 Name and locate the outputfile.
            TestInput2.Open("../../TestData/InputData/FindAveregeSlopeExtented/PolygonIron.shp");
            TestOutput.Filename = ("../../TestData/OutputData/FindAveregeSlopeExtented/OutputFindAveregeSlopeExtented.shp");
            //3 Get the Object and Execute the function
            double inZFactor = 1.0;
            bool slopeInPercent = true;
            string fldInPolyToStoreSlope = "Ave_Slope";
            int outerShpIndex = 0;	
            MapWindowTools.Terrain_Analysis.mwFindAveregeSlopeExtented FindAveregeSlopeExtented = new MapWindowTools.Terrain_Analysis.mwFindAveregeSlopeExtented();
            FindAveregeSlopeExtented.Execute(TestInput1, inZFactor, slopeInPercent, TestInput2, fldInPolyToStoreSlope, TestInput2, outerShpIndex, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open(@"../../TestData/CorrectOutput/FindAveregeSlopeExtented/CorrectFindAveregeSlopeExtented.shp");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("FindAveregeSlopeExtented function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
            }
            else
                if (CompareFeatures(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("FindAveregeSlopeExtented function passed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
                else
                {
                    lstOutput.Items.Add("FindAveregeSlopeExtented function failed testing in " + TestInput1.Filename.ToString() + " and " + TestInput2.ToString());
                }
            lstOutput.Update();
        }
        //RasterSlope
        void TestRasterSlope(ICancelProgressHandler CancelHandle)
        {
            lstOutput.Items.Add("Now testing RasterSlope function");
            lstOutput.Update();
            Raster TestInput = new Raster();
            Raster TestOutput = new Raster();
            Raster TestCorrect = new Raster();
            //1 open the input file
            TestInput.Open("../../TestData/InputData/RasterSlope/iron1.bgd");
            //2 Name and locate the outputfile.
            TestOutput.Filename = ("../../TestData/OutputData/RasterSlope/OutputRasterSlope.bgd");
            //3 Get the Object and Execute the function
            double inZFactor = 1.0;
            bool slopeInPercent = true;	
            MapWindowTools.mwRasterSlope TestRasterSlope = new MapWindowTools.mwRasterSlope();
            TestRasterSlope.Execute(TestInput, inZFactor, slopeInPercent, TestOutput, CancelHandle);
            //4 Open a "known" correct output file  
            TestCorrect.Open("../../TestData/CorrectOutput/RasterSlope/CorrectRasterSlope.bgd");
            //5 Compare the output with the correct file and pass some information to the lstbox about the progress and whether the test failed or passed
            if (CompareBinary(TestOutput.Filename, TestCorrect.Filename) == true)
            {
                lstOutput.Items.Add("RasterSlope function passed testing in " + TestInput.Filename.ToString());
            }
            else
                if (CompareRasterValues(TestOutput, TestCorrect))
                {
                    lstOutput.Items.Add("RasterSlope function passed testing in " + TestInput.Filename.ToString());
                }
                else
                {
                    lstOutput.Items.Add("RasterSlope function failed testing in " + TestInput.Filename.ToString());
                }
            lstOutput.Update();
        }
    }
    //

}
